<?php
    /* 版块分类显示页
     * @author zhangnanya 
     * @time 2020.6.5
     *  */
require_once '../inc/config.php';/* 得到session_start */
require_once '../inc/section.php';/*调用查找板块方法*/
require_once '../inc/book.php';
require_once 'header.php';
?>
<!-- 帖子列表 -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE>书籍分类-阅读记</TITLE>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<link rel="stylesheet" href="../css/section.css">
		<script type="text/javascript" src="../inc/jquery-2.1.1.min.js"></script>
		<script src="../script/section.js"></script>
</HEAD>
<body>
<?php  
$sectionId=$_GET["sectionId"];//板块编号
$sectionName=$_GET["sectionName"];//板块名称
$curPage=$_GET['currentPage'];//设置当前是第几页
$msg="";//出错信息
$cursection=array();//当前板块信息
if(isset($sectionId)){//判断是否查询到内容
    $cursection=findsectionId($sectionId);//查询到指定板块信息
    if(count($cursection)>=0){
        $sectionName=$cursection["sectionName"];
    }else{
        $msg="板块不存在！";
    }
}else{
    $msg="板块编号不存在";
}
if($msg!=""){
    header("location: ../style/errorNew.php?msg=$msg");//转入出错页面
}
$bookList=findListbook($curPage, $sectionId);//分页取指定版块的书本列表
$bookNums=findCountbook($sectionId);//统计板块的书本数
$pageSize=$GLOBALS["cfg"]["server"]["page_size"];//页面容量
$pages=ceil($bookNums/$pageSize);//计算总页数
//$book=findsectionId($sectionId);//取指定版块的书本列表
//计算总页数
?>
 <DIV class="t"> 
           <!-- 分类导航条 -->
				<div class="navSub" id="navSub">
					<div class="nav">
				<?php 
					$section=getSection();
					$li="";
					for($i=0;$i<count($section);$i++){
					$sectioName=$section[$i]["sectionName"];
					$sectionId=$section[$i]["sectionId"];
					$li.=<<<li
                   
                    <font id="section">
                    <span ><a href="section.php?sectionId=$sectionId&currentPage=1">$sectioName</a></span> 
                    <div class="ww" style="background:#ffffff;width:10px;"></div>                          
li;
                     }     
						  echo $li;
						?>    
                </div>
                </div>	
                </DIV>
 <!-- 书籍分类显示 -->			
     <div class="books">
	 <TABLE style="border:1px solid #ccc;">  
       <?php
          $html_topic="";
          foreach ($bookList as $book){//遍历帖书本记录
              $bookId=$book["bookId"];
              $bookPic=$book["bookPic"];
              $bookName=$book["bookName"];
              $writer=$book["writer"];
              $introduction=$book["introduction"];
              $firstTime=$book["firstTime"];
              if($firstTime==""){$firstTime="***";}
              $html_topic.=<<<HTML_TABLE
              <ul><div class="box">
              <div class="content"><a href="book.php?sectionId=$sectionId&bookId=$bookId"><img src="../image/book/$bookPic" width="180px" height="200px";/></a>
              </div>
              <a href="book.php?sectionId=$section&bookId=$bookId" id="name"><br><p>$bookName</p><br></a>
              <p>&nbsp;&nbsp;作者：$writer</p> 
              <P>&nbsp;&nbsp;出版时间：$firstTime 年</p><br><br><br><br> 
              <p id="int">简介：$introduction</p> 
               </div>           
             </ul>
HTML_TABLE;
          }
          echo $html_topic;//输出书本列表信息
          ?>  
          </TABLE>				
<!--   	<div class="post"><a href="post.php?sectionId=<?php $sectionId?>&bookId=<?php $bookId?>"><img src="../image/section/post.JPG" width="100px" height="100px";/></a><p style="font-color:pink;font-family:幼圆;background:pink;">发布阅读分享</p></div>
       </div>	 -->
         
          <br>         
	<!-- 分页显示 -->
	<DIV class="padding">
	<?php
	$PageSize=$GLOBALS["cfg"]["server"]["page_size"];//页面容量
    $sectionId=$_GET["sectionId"];//板块编号
    $curPage = $_GET['currentPage'];//设置当前是第几页
    $bookList=findListbook($curPage, $sectionId);//分页取指定版块的书本列表
    $bookNums=findCountbook($sectionId);//统计板块的书本数
    $pages=ceil($bookNums/$PageSize);//计算总页数
    
	$page_previous = ($curPage<=1)?1:$curPage-1;  //上一页
	$page_next = ($curPage>=$pages)?$pages:$curPage+1;  //下一页
	$page_next = ($page_next==0)?1:$page_next;//没有记录时，$page_next的最小值为1
	$navigator = "<a style='text-decoration:none;' href='section.php?sectionId=$sectionId&currentPage=$page_previous' >&nbsp;<b>上一页&nbsp;</b></a>";
	
	for($i=0;$i<$pages;$i++){
	    $j= $i+1;
	    $navigator.="<a style='text-decoration:none;' href='section.php?sectionId=$sectionId&currentPage=$j'>&nbsp;$j&nbsp;</a>  ";
	}
	
	$navigator.="<a style='text-decoration:none;' href='section.php?sectionId=$sectionId&currentPage=$page_next'>&nbsp;<b>下一页</b></a>&nbsp;&nbsp;&nbsp;";
	$navigator.= "共".$bookNums."条记录，共".$pages."页，当前是第".$curPage."页";
	echo $navigator;
	?>
      </div>  
         <?php require_once 'footer.php'; ?>
      </body>     
</HTML>